home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / ddjhptxt.arc / SWAINE.LST < prev    next >
File List  |  1990-06-05  |  3KB  |  98 lines

  1. LISTING ONE
  2.  
  3. on mousewithin
  4.   --
  5.   --hypertext technique by Steve Drazga, AnalytX
  6.   --if you use this in your scripts please include these 2 lines.
  7.   --
  8.     if the locktext of the target is true then
  9.       set locktext of target to false --unlock the field if it is
  10. locked
  11.    end if
  12.  
  13.    if selection is not empty then --something was selected
  14.       put selection into SelectedWord
  15.       if space is in SelectedWord then --user selected > 1 word
  16.          click at loc of target --so we will clear the selection
  17.          exit mousewithin --and exit to wait for another
  18. selection
  19.       end if
  20.     --
  21.     --this is the section where you do something with the selection
  22.     --You can bring up a pop up note or you can go to another card.
  23.     --
  24.     end if
  25. end mousewithin
  26.  
  27.  
  28. LISTING TWO
  29.  
  30. on mouseUp
  31.  
  32.   -- This code, placed in a button script, implements
  33.   -- Harvey Chang's hypertext trick.  The user selects
  34.   -- any text in a field and clicks on the button.
  35.   -- The script first tries to use the selected text as a
  36.   -- hypertext link, then falls back to simple search.
  37.  
  38.   doMenu Copy Text
  39.   put "Montreal Hypertext, Harvey Y Chang MD, 1988 Jan 16"
  40.   push card
  41.   go to Montreal Hypertext Demo
  42.   doMenu Find...
  43.   doMenu Paste Text
  44.   put " in field " & quote & "Title" & quote after message
  45.   do message
  46.   if the result is "not found" then
  47.     answer "not found in Titles:  search text?" with "OK" or "No"
  48.     if it is "No" then
  49.       pop card
  50.       exit mouseUp
  51.     else
  52.       doMenu Find...
  53.       doMenu Paste Text
  54.       put " in field " & quote & "Text" & quote after message
  55.       do message
  56.     end if
  57.   end if
  58. end mouseUp
  59.  
  60.  
  61. LISTING THREE
  62.  
  63. on mouseUp
  64.  
  65.   -- This is a scrolling field script.  Its field must be locked.
  66.   -- It implements an index field, to be placed on the first
  67.   -- card of the stack to be indexed.  This is the index card.
  68.   -- When the mouse is clicked inside the field, this script causes
  69.   -- a jump to the card corresponding to the line clicked on.
  70.   -- The line commented out uses the text in the line,
  71.   -- rather than its number, as the link.
  72.  
  73.   go to card getLineNum(the mouseV)
  74.   -- find line getLineNum(the mouseV) of me in field keyword
  75.  
  76. end mouseUp
  77.  
  78. function getLineNum mouseVert
  79.  
  80.   -- Returns the number of the line clicked on.
  81.  
  82.   -- It works like this:
  83.   -- Subtracting the top of the field and its scroll from
  84.   -- the mouse's vertical location gives the
  85.   -- mouse's vertical location within the field.
  86.   -- Dividing this by the textHeight of the field & adding 0.5
  87.   -- converts pixel counts to line counts.
  88.   -- Rounding gives a value acceptable as a card number.
  89.  
  90.   -- Note: although this technique should work with any font size,
  91.   -- turning on WideMargins will confuse the count.
  92.   -- To adapt this script to a non-scrolling field,
  93.   -- remove "+ the scroll of me" from the computation.
  94.  
  95.   return round(((mouseVert - the top of me + the scroll of me) /
  96. (the textHeight of me)) + 0.5)
  97.  
  98. end getLineNum